public class test1 {
    //力扣 58.子数组的最大和
    public int maxSubArray(int[] nums) {
        //创建dp表
        //初始化
        //填表
        //返回值
        int n = nums.length;
        int[] dp = new int[n+1];
        dp[0] = 0;
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<n+1;i++){
            dp[i] = Math.max(nums[i-1],dp[i-1]+nums[i-1]);
            max = Math.max(max, dp[i]);
        }
        return max;
    }
}
